<!--
 * @Author: your name
 * @Date: 2020-02-25 13:32:39
 * @LastEditTime: 2020-02-28 11:25:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \福路德扫码系统\html\cksm.html
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../css/local.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .title {
            font-size: 17px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            padding-right: 10px;
        }

        .date {
            float: right;
            font-size: 12px;
            color: #cbcbcb;
        }

        .sub {
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            font-size: 14px;
            color: #a3a3a3;
        }

        .creater {
            font-size: 14px;
        }

        .creater2{
            font-size: 12px;
        }

        .result span {
            background: #fdf9f8;
            border: 1px solid #eeebec;
            border-radius: 10px;
            font-size: 12px;
            transform: scale(0.9);
            display: inline-block;
            height: 16px;
            line-height: 14px;
            padding: 0 2px;
        }

        .status-0 span {
            transform: scale(1);
            border: 0;
            background: #ffffff;
            color: #e3b474;
        }

        .status-1 span {
            color: #47ba9c;
        }

        .status-2 span {
            color: #dd7e70;
        }

        .bo {
            padding-top: 10px;
        }

        .sq {
            display: inline-block;
            font-size: 13px;
            padding: 0 2px;
            margin-right: 5px;
            min-width: 16px;
            height: 18px;
            line-height: 18px;
            border-radius: 4px;
            text-align: center;
            background-color: #3396fb;
            color: #ffffff;

        }

        .title span {
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" style="user-select:none;">
            <van-nav-bar-main :title="titleName" left-arrow @click-left="onClickLeft">
                <!-- <div slot="right">
                    <span @click="showSearch = true;">
                        <van-icon name="search" size="18px"></van-icon>
                    </span>
                </div> -->
            </van-nav-bar-main>
            <div class="content">
                <van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了" @load="listOnLoad">
                    <van-cell-group>
                        <van-cell @click="intoRow(row)" v-for="(row,index) in dataList">
                            <div>
                                
                                <van-row>
                                    <van-col span="24">
                                        <div class="flex-box">
                                            <div class="flex-main title"><span
                                                    class="sq">{{index+1}}</span><span>{{row.Title}}</span></div>
                                            <div class="date">{{row.CreateTime}}</div>
                                        </div>
                                    </van-col>
                                    <van-col span="24">
                                        <div v-html="returnSub(row.FRemarks)"></div>
                                    </van-col>
                                    <van-col span="24">
                                        <div class="flex-box bo">
                                            <div class="flex-main creater">由{{row.Creater}}发起</div>
                                            <div class="result" :class="'status-' + row.RZSPJG">
                                                <span>{{getApprovalText(row.RZSPJG)}}</span>
                                            </div>
                                        </div>
                                        <div class="flex-box bo" v-if="vm.type==6">
                                            <div class="flex-main creater2">待<span style="color:red;">{{row.CurrentApprovalUserName}}</span>审批</div>
                                            <div class="creater2">已等待<span style="color:red;">{{row.WaitDate}}</span></div>
                                        </div>
                                        <div v-if="type==99">
                                            <van-tag v-if="!row.IsRead" type="danger" size="medium" style="float:right">未读</van-tag><van-tag v-else type="success" size="medium" style="float:right">已读</van-tag>
                                        </div>
                                    </van-col>
                                </van-row>
                            </div>
                        </van-cell>
                    </van-cell-group>


                </van-list>

            </div>
        </div>

        <!-- <div class="fix-button">
            <van-button color="#2fa2b9" type="primary" block style="border-radius: 0;" @click="addNew">新增
            </van-button>
        </div> -->


        <van-popup v-model="showSearch" position="bottom">
            <div style="padding-bottom: 10px;">
                <van-cell title="开始时间" :value="searchData.S_SDate" @click="openDate(1)">
                </van-cell>
                <van-cell title="结束时间" :value="searchData.S_EDate" @click="openDate(2)">
                </van-cell>
            </div>
            <div class="btn-padding">
                <van-button color="#2fa2b9" type="primary" block style="border-radius: 0;" @click="searchList">查询
                </van-button>
            </div>
        </van-popup>


        <van-popup v-model="showDate" position="bottom">
            <van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
                cancel-button-text="清空" />
        </van-popup>
    </div>
</body>
<script type="text/javascript">
    var vm;
    apiready = function () {

        api.addEventListener({
            name: 'refreshList'
        }, function (ret, err) {
            vm.pageIndex = 1;
            vm.getDataList();
        })

        var dateIndex = 0;




        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,

                titleName: api.pageParam.titleName,
                type: api.pageParam.type,

                listLoading: false,
                listFinished: true,
                pageSize: 20,
                pageIndex: 1,
                dataList: [],
                currentDate: new Date(),
                showDate: false,
                searchData: {
                    S_SDate: APP.getFormatDate().split(' ')[0],
                    S_EDate: APP.getFormatDate().split(' ')[0]
                }
            },
            created: function () {
                var that = this;
                that.getDataList();
            },
            methods: {
                getDataList: function () {
                    var that = this;
                    that.showLoading = true;
                    var obj = {
                        FType: that.type,
                        page: that.pageIndex,
                        size: that.pageSize
                    }
                    // console.log('obj', JSON.stringify(obj))
                    APP.ajax('GetUserFlowLog1', obj, function (res) {
                        that.showLoading = false;
                        that.listFinished = false;
                        that.dataList = res.ds;
                    })

                },
                returnSub: function (str) {
                    var that = this;
                    if (str) {
                        var strArray = str.split('|');
                        var html = '';
                        for (var i in strArray) {
                            html += '<div class="sub">' + strArray[i] + '</div>';
                        }
                        return html;
                    } else {
                        return '';
                    }
                },
                getApprovalText: function (status) {
                    var that = this;
                    if (status == 0) {
                        return '审批中'
                    }
                    if (status == 1) {
                        return '审批通过'
                    }
                    if (status == 2) {
                        return '审批拒绝'
                    }

                },
                listOnLoad: function () {
                    var that = this;
                    that.pageIndex++;
                    var obj = {
                        FType: that.type,
                        page: that.pageIndex,
                        size: that.pageSize
                    }
                    APP.ajax('GetUserFlowLog1', obj, function (res) {
                        that.listLoading = false;
                        if (res.ds.length == 0) {
                            that.listFinished = true;
                        }
                        that.dataList = that.dataList.concat(res.ds);
                    })
                },
                searchList: function () {
                    var that = this;
                    that.showSearch = false;
                    that.pageIndex = 1;

                    this.getDataList();
                },
                openDate: function (index) {
                    dateIndex = index;
                    this.currentDate = new Date()
                    this.showDate = true;
                },
                confirmDate: function (value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = APP.getFormatDate(value).split(' ')[0]
                    } else {
                        this.searchData.S_EDate = APP.getFormatDate(value).split(' ')[0]
                    }
                    this.showDate = false;
                },
                cancelDate: function (value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = ''
                    } else {
                        this.searchData.S_EDate = '';
                    }
                    this.showDate = false;
                },
                intoRow: function (row) {
                    var that = this;
                    var page = '';
                    // alert(row.TableName)
                    //如果是我的审批，点击后为已读
                    if(that.type==99){
                        APP.ajax('updateCkRead', {AuditID: row.AuditID
					    }, function (data) {row.IsRead = 1});
                    }





                    if (row.TableName == 'Ck_Review') {
                        page = 'approvalPage1';
                    } else if (row.TableName == 'Ck_ReviewLine') {
                        page = 'approvalPage15';
                    }else if (row.TableName == 'EC_ProjectChgRevRec') {
                        page = 'approvalPage2';
                    } else if (row.TableName == 'EC_ProjectChgPrcCfm') {
                        page = 'approvalPage3';
                    } else if (row.TableName == 'PU_AppVouchM') {
                        page = 'approvalPage4';
                    } else if (row.TableName == 'Si_Order') {
                        page = 'approvalPage10';
                    } else if(row.TableName == 'PU_BatchApproval'){
                        page = 'approvalPage13';
                    } else if (row.TableName == 'Pr_Improve') {
                        page = 'approvalPage11';
                    } else if(row.TableName=='Ck_ExperimentReview'){
                        page = 'approvalPage14';
                    }
                    else if (row.TableName == 'AP_ProgramStage') {
                        page = 'approvalPage8';
                    } 
                    else if(row.TableName == 'Ck_TrialData'){
                        page = 'approvalSZPage';
                    }
                    else if(row.TableName == 'CK_ExperimentPlan'){
                        page = 'approvalPage30';
                    }
                    else if (row.TableName == 'Bas_Approval') {

                        if (row.Title.indexOf('转正') > -1) {
                            page = 'approvalPage5';
                        } else if (row.Title.indexOf('请假') > -1) {
                            page = 'approvalPage6';
                        } else if (row.Title.indexOf('离职') > -1) {
                            page = 'approvalPage7';
                        } else if (row.Title.indexOf('异动') > -1 || row.Title.indexOf('调岗') > -1) {
                            page = 'approvalPage9';
                        } else if (row.Title.indexOf('加班') > -1) {
                            page = 'approvalPage12';
                        }
                    }
                    api.openWin({
                        name: page,
                        url: page + '.html',
                        reload: true,
                        slidBackEnabled: false,
                        allowEdit: true,
                        pageParam: {
                            id: row.PKValue
                        }
                    })

                },
                onClickLeft: function () {
                    api.closeWin();
                }
            }
        })

    };
</script>

</html>
